/**
 * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function main(): int {
    let failCounter: int = 0;
    let testResult: int = 0;
    let arrayValue : ArrayValue = Value.of([{{.item.init_values | first}}] as FixedArray<{{.item.name}}>) as ArrayValue;
    let actualValue : {{.item.value_name}}Value;
    let storedValue : {{.item.value_name}}Value;
    if (arrayValue.getLength() == 1) {
      testResult = 1;
    } else {
      testResult = 0;
    }
    printTestVerdict(testResult, "Length of array is 1");
    {% for init_value in item.init_values %}
      actualValue = Value.of({{.init_value}}) as {{.item.value_name}}Value;
      arrayValue.setElement(0, actualValue);
      storedValue = arrayValue.getElement(0) as {{.item.value_name}}Value;
      {% if item.primitive %}
      testResult = checkTestResult(actualValue.getValueData() as {{.item.name}}, storedValue.getValueData() as {{.item.name}});
      {% else %}
      testResult = checkTestResult(actualValue.getData() as {{.item.name}}, storedValue.getData() as {{.item.name}});
      {% endif %}
      printTestVerdict(testResult, "Element of array of {{.item.name}} type");
      failCounter += testResult;
    {% endfor %}
    if (failCounter > 0) return 1
    return 0;
}

function printTestVerdict(flag: int, testName: String) {
    if (flag == 0) {
      console.println(testName + " : PASSED")
    } else {
      console.println(testName + " : FAILED")
    }
}
